<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
	layout:decorator="admin/layout">
<head>
<title>充值卡管理</title>
<script th:inline="javascript">
	/*<![CDATA[*/
	$.validator.addMethod('typeAllowed', function(value, element) {
		var suffix = value.split('.').pop().toLowerCase();
		if (!(suffix.match(/jpg|jpeg|png|gif/i))) {
			return false;
		} else {
			return true;
		}
	}, '上传的图片类型只能是png,gif,jpg,jpeg');
	function uploadFile(e) {
		$('#imgFile').click();
	}

	function uploadFile2(e) {
		if ($(e).val() != null) {
			var filename = $(e).val().substr($(e).val().lastIndexOf('\\') + 1);
			if (!($(e).val().split('.').pop().toLowerCase()
					.match(/jpg|jpeg|png|gif/i))) {
				$('#file_upload_help').show();
				return false;
			} else {
				$('#file_upload_help').hide();
			}
			$('#file_upload_span').html(filename);
			$('#form_brand_image').submit();
		}
	}
	function checkHead(val){
		if(/^[1-9]d*|0$/.test(val) || /^[A-Za-z]+$/.test(val) && val.length <=3) {
		}else{
			$("#card_head").val("");
		}
	}
	
	 $(document).ready(function(){

		 $("#cardForm").validate({
	         rules:{
	        	 name:{
	            	 required:true,
	            	 maxlength:10
	             },price:{
	            	 required:true,
	            	 number:true,
	                 max:999999999.00
	             },get_time:{
	            	 required:true,
	            	 number:true,
	            	 range:[0,500]
	             },add_gold:{
	            	 required:true,
	            	 number:true,
	                 max:999999999.00
	             },add_experience:{
	            	 required:true,
	            	 range:[0,10]
	             }
	             
	             
	             
	              
	         },
	         messages:{
	             name:{
	                 required:"请输入名称"
	             },price:{
	                 required:"请输入价格",
	                 number:"请输入正确的金额",
	                 max:'本店售价最大值为99999999.99且必须为数字'
	             },get_time:{
	                 required:"请输VIP时长"
	             },add_gold:{
	                 required:"请输入绑定用户ID",
	                 number:"请输入正确的金额",
	                 max:'本店售价最大值为99999999.99且必须为数字'
	             },add_experience:{
	            	 required:"请输入进货折扣"
	             }
	             
	         }
	         
	      });
		 
	  });
	/*]]>*/
</script>
</head>
<body>
	<div layout:fragment="content">
		<div class="row">
			<div class="col-md-12">
				<div class="btn-group pull-right">
					<a href="index.html" th:href="@{/admin/money/card/index/}" id="sample_editable_1_new" class="btn green">返回<i class="fa fa-arrow-circle-o-left"></i></a>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="form">
					<form role="form" th:action="@{/admin/money/card/save}" th:object="${card}"
						id="cardForm" method="post" class="form-horizontal">
						<h4 class="form-section">充值卡信息</h4>
						<input type="hidden" th:field="*{id}" />
						<div class="form-body">
							<div class="form-group"
								th:class="${#fields.hasErrors('name')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">充值卡名称:<span
									class="required" aria-required="true">* </span></label>
								<div class="col-md-4">
									<input type="text" class="form-control" placeholder="商户名称" th:field="*{name}" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">图片上传：</label>
								<div class="col-md-7">
									<input type="text" id="logo" th:field="*{pricture}" />
									<div class="form-control" style="padding: 0;">
										<span style="padding-left: 5px;" id="file_upload_span"
											name="file_upload_span">未选择文件</span><input type="button"
											class="btn blue pull-right" onclick="uploadFile(this)"
											value="浏览" />
									</div>
									<p class="help-block text-center"
										style="color: red; display: none;" id="file_upload_help">上传的图片类型只能是png,gif,jpg,jpeg</p>
								</div>
							</div>
							<div class="form-group"
								th:class="${#fields.hasErrors('price')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">充值卡价格:<span
									class="required" aria-required="true">* </span></label>
								<div class="col-md-4">
									<input type="text" class="form-control" placeholder="充值卡价格" th:field="*{price}" />
								</div>
							</div>
							<div class="form-group"
								th:class="${#fields.hasErrors('card_head')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">自定义卡头:<span
									class="required" aria-required="true">* </span></label>
								<div class="col-md-1">
									<input type="text" id="card_head" class="form-control" placeholder="自定义卡头" th:field="*{card_head}" onchange="checkHead(this.value);" maxlength="3"/>
									<span style="color:red;">* </span>0~3位英文或数字,推荐2位
								</div>
							</div>
							<div class="form-group"
								th:class="${#fields.hasErrors('random_num')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">随机位数:<span
									class="required" aria-required="true">* </span></label>
								<div class="col-md-4">
									<select id="random_type" class="form-control"  th:field="*{random_num}">
									<option value="5">5位</option>
									<option value="6">6位</option>
									<option value="7">7位</option>
									<option value="8">8位</option>
									<option value="9">9位</option>
									<option value="10">10位</option>
									<option value="11">11位</option>
									<option value="12">12位</option>
									<option value="13">13位</option>
									<option value="14">14位</option>
									<option value="15">15位</option>
									<option value="16">16位</option>
									<option value="17">17位</option>
									<option value="18">18位</option>
									<option value="19">19位</option>
									<option value="20">20位</option>
									</select>
								</div>
							</div>
							<div class="form-group"
								th:class="${#fields.hasErrors('random_type')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">随机数类型:<span
									class="required" aria-required="true">* </span></label>
								<div class="col-md-4">
									<select id="random_type" class="form-control"  th:field="*{random_type}">
									<option value="1">数字</option>
									<option value="2">数字+大写字母</option>
									<option value="3">数字+大写字母+小写字母</option>
									</select>
								</div>
								
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">修改ID:</label>
								<div class="col-md-4">
									<div class="radio-list">
										<label class="radio-inline"> <span> <input
												id="radio_displayed_1" type="radio" value="1" checked=""
												th:field="*{update_id}" />
										</span>是
										</label> <label class="radio-inline"><span><input
												id="radio_displayed_2" type="radio" value="0"
												th:field="*{update_id}" /></span> 否</label>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">升级VIP:</label>
								<div class="col-md-4">
									<div class="radio-list">
										<label class="radio-inline"> <span> <input
												id="radio_displayed_1" type="radio" value="1" checked=""
												th:field="*{isVip}" />
										</span>是
										</label> <label class="radio-inline"><span><input
												id="radio_displayed_2" type="radio" value="0"
												th:field="*{isVip}" /></span> 否</label>
									</div>
								</div>
							</div>
							<div class="form-group"
								th:class="${#fields.hasErrors('get_time')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">VIP时长:<span
									class="required" aria-required="true">* </span></label>
								<div class="col-md-4">
									<input type="text" class="form-control" placeholder="VIP时长" th:field="*{get_time}" />
								</div>
							</div>
							<div class="form-group"
								th:class="${#fields.hasErrors('add_gold')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">增加金币:<span
									class="required" aria-required="true">* </span></label>
								<div class="col-md-4">
									<input type="text" class="form-control" placeholder="增加金币" th:field="*{add_gold}" />
								</div>
							</div>
							<div class="form-group"
								th:class="${#fields.hasErrors('add_experience')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">增加经验:<span
									class="required" aria-required="true">* </span></label>
								<div class="col-md-4">
									<input type="text" class="form-control" placeholder="增加经验" th:field="*{add_experience}" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">道具中心显示:</label>
								<div class="col-md-4">
									<div class="radio-list">
										<label class="radio-inline"> <span> <input
												id="radio_displayed_1" type="radio" value="1" checked=""
												th:field="*{display}" />
										</span>是
										</label> <label class="radio-inline"><span><input
												id="radio_displayed_2" type="radio" value="0"
												th:field="*{display}" /></span> 否</label>
									</div>
								</div>
							</div>
							<div class="form-group"
								th:class="${#fields.hasErrors('buy_url')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">购买地址:<span
									class="required" aria-required="true"></span></label>
								<div class="col-md-4">
									<input type="text" class="form-control" placeholder="购买地址" th:field="*{buy_url}" />
								</div>
							</div>
							<div class="form-group"
								th:class="${#fields.hasErrors('buy_url')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">充值卡介绍:<span
									class="required" aria-required="true"></span></label>
								<div class="col-md-4">
									<input type="text" class="form-control" placeholder="购买地址" th:field="*{buy_url}" />
								</div>
							</div>
						<div class="form-group"
								th:class="${#fields.hasErrors('content')}? 'form-group has-error' : 'form-group'">
								<label class="control-label col-md-3">商户备注:<span
									class="required" aria-required="true"></span></label>
								<div class="col-md-4">
									<input type="text" class="form-control" placeholder="商户备注" th:field="*{content}" />
								</div>
							</div>

						</div>
						<div class="form-actions fluid">
							<div class="col-md-offset-3 col-md-9">
								<button type="submit" class="btn blue" name="sub">提交</button>
							</div>
						</div>
					</form>
				</div>
			</div>
			<div style="display: none;">
				<form target="iframe_brand_image" action="/upload/CARD"
					enctype="multipart/form-data" method="post" id="form_brand_image"
					name="form_brand_image">
					<input type="file" id="imgFile" onchange="uploadFile2(this)"
						name="imgFile" />
				</form>
			</div>
			<iframe style="display: none;" id="iframe_brand_image"
				name="iframe_brand_image" frameborder="0"></iframe>
			
		</div>
	</div>
</body>
</html>